{% extends "../layouts/admin.html" %} {% block content %}
<header class="header navbar bg-white shadow">
  <div class="btn-group tool-button">
    <a class="btn btn-primary navbar-btn" href="/weixin/config/index" data-pjax id="goback"><i class="ti-angle-left"></i> 返回</a>
  </div>
</header>

<div class="content-wrap">
  <div class="wrapper" style="min-height:500px;">
    <section class="panel panel-form">
      <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
            action="/weixin/config/edit" method="post">
        <input id="id" name="id" value="{{conf.id}}" type="hidden">
        <div class="row mb10">
          <div class="col-lg-12">
            
            <div class="form-group">
              <label for="appname" class="col-sm-2 control-label">公众号名称</label>

              <div class="col-sm-8">
                <input type="text" id="appname" class="form-control" name="appname" data-parsley-required="true"
                       placeholder="公众号名称" value="{{conf.appname}}">
              </div>
            </div>
            <div class="form-group">
              <label for="ghid" class="col-sm-2 control-label">原始ID</label>

              <div class="col-sm-8">
                <input type="text" id="ghid" class="form-control" name="ghid" data-parsley-required="true"
                       placeholder="原始ID" value="{{conf.ghid}}">
              </div>
            </div>
            <div class="form-group">
              <label for="appid" class="col-sm-2 control-label">Appid</label>

              <div class="col-sm-8">
                <input type="text" id="appid" class="form-control" name="appid" data-parsley-required="true"
                       placeholder="appid" value="{{conf.appid}}">
              </div>
            </div>
            <div class="form-group">
              <label for="appsecret" class="col-sm-2 control-label">Appsecret</label>

              <div class="col-sm-8">
                <input type="text" id="appsecret" class="form-control" name="appsecret" data-parsley-required="true"
                       placeholder="appsecret" value="{{conf.appsecret}}">
              </div>
            </div>
            <div class="form-group">
              <label for="encodingAESKey" class="col-sm-2 control-label">EncodingAESKey</label>

              <div class="col-sm-8">
                <input type="text" id="encodingAESKey" class="form-control" name="encodingAESKey" data-parsley-required="true"
                       placeholder="encodingAESKey" value="{{conf.encodingAESKey}}">
              </div>
            </div>
            <div class="form-group">
              <label for="token" class="col-sm-2 control-label">Token</label>

              <div class="col-sm-8">
                <input type="text" id="token" class="form-control" name="token" data-parsley-required="true"
                       placeholder="token" value="{{conf.token}}">
              </div>
            </div>
            <!--<div class="form-group">
              <label for="qrcode" class="col-sm-2 control-label">二维码</label>

              <div class="col-sm-8">
                <div id="queue"></div>
                <div class="input-group">
                  <input id="file_upload" name="file_upload" type="file" multiple="false">
                  <span class="input-group-btn">
                  <button class="btn btn-color current-time" type="button"
                          onclick="$('#file_upload').uploadifive('upload')">上传<i class="ti-upload ml5"></i></button>
                  </span>
                </div>
                <div id="img" style="padding: 5px;">
                  {% if conf.qrcode %}
                  <img src='{{conf.qrcode}}' style='width:150px;'>
                  <i class="fa fa-close" onclick="$('#qrcode').val('');$('#img').html('');"></i>
                  {% endif %}
                </div>
                <input type="hidden" id="qrcode" name="qrcode" value="{{conf.qrcode}}" >
              </div>
            </div>-->
          </div>
        </div>
        <div class="col-lg-3"></div>
        <div class="col-lg-6">
          <div class="form-group text-center">
            <label></label>

            <div>
              <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
            </div>
          </div>
        </div>
      </form>
    </section>

  </div>
</div>
<script language="JavaScript">
  function clearFile() {
    $("#img").html("");
    $("#qrcode").val("");
  }
  $(document).ready(function () {
//  $('#file_upload').uploadifive({
//    'auto': false,
//    'multi': false,
//    'width': '100%',
//    'height': '35',
//    'buttonText': '请选择图片',
//    'fileType': 'image/*',
//    'fileSizeLimit': 1024,
//    'queueSizeLimit': 1,
//    'formData': {},
//    'queueID': 'queue',
//    'uploadScript': '/weixin/config/image',
//    'onUploadComplete': function (file, data) {
//      data = JSON.parse(data);
//      if (data.code == 0) {
//        Toast.success(data.msg);
//        $("#img").html("<img src='" + data.path + "' style='width:150px;'>");
//        $("#qrcode").val(data.path);
//      } else {
//        clearFile();
//        Toast.error(data.msg);
//      }
//    },
//    'onDrop': function (file, fileDropCount) {
//      clearFile();
//    },
//    'onClearQueue': function (queue) {
//      clearFile();
//    },
//    'onCancel': function () {
//      clearFile();
//    }
//  });
    $('#addForm').ajaxForm({
      dataType: 'json',
      beforeSubmit: function (arr, form, options) {
        form.find("button:submit").button("loading");
      },
      success: function (data, statusText, xhr, form) {
        if (data.errno == 0) {
          Toast.success(data.data);
          setTimeout(function () {
            $("#goback").trigger("click");
          }, 1000);
        } else {
          Toast.error(data.errmsg);
        }
        form.find("button:submit").button("reset");
      }
    });
  });
</script>
{% endblock %}